package com.waterstudio.filedownloader.ext.m3u8.bean;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.waterstudio.filedownloader.ext.m3u8.BuildConfig;

import java.util.ArrayList;
import java.util.List;


/**
 * ================================================
 * 作    者：JayGoo
 * 版    本：
 * 创建日期：2017/11/20
 * 描    述: m3u8实体类
 * ================================================
 */
public class M3U8 {
    @NonNull
    private String mBasePath;
    /**
     * M3U8 文件保存路径
     */
    @Nullable
    private String mM3U8FilePath;
    /**
     * 如果是一个 master playlist 那么不为 NULL
     */
    private List<MasterList> mMasterLists = new ArrayList<>();
    /**
     * 如果是一个 media playlist ,那么不应该为空
     */
    private List<M3U8Ts> mTsArrayList = new ArrayList<M3U8Ts>();//视频切片

    public M3U8(@NonNull String basePath) {
        mBasePath = basePath;
    }

    public List<MasterList> getMasterLists() {
        return mMasterLists;
    }

    @NonNull
    public String getBasePath() {
        return mBasePath;
    }


    public String getM3U8FilePath() {
        return mM3U8FilePath;
    }

    public void setM3U8FilePath(String m3U8FilePath) {
        this.mM3U8FilePath = m3U8FilePath;
    }


    public List<M3U8Ts> getTsArrayList() {
        return mTsArrayList;
    }

    public void setTsArrayList(List<M3U8Ts> tsArrayList) {
        this.mTsArrayList = tsArrayList;
    }

    public void addMaster(MasterList masterList) {
        this.mMasterLists.add(masterList);
    }

    public void addTs(M3U8Ts ts) {
        this.mTsArrayList.add(ts);
    }

    public boolean isMasterPlaylist() {
        return !mMasterLists.isEmpty();
    }


    @Override
    public String toString() {
        if (BuildConfig.LOG_ENABLE) {
            return "M3U8{" +
                    "basePath='" + mBasePath + '\'' +
                    ", m3U8FilePath='" + mM3U8FilePath + '\'' +
                    ", masterLists=" + mMasterLists +
                    ", tsArrayList=" + mTsArrayList +
                    '}';
        } else {
            return "{" +
                    "='" + mBasePath + '\'' +
                    ", ='" + mM3U8FilePath + '\'' +
                    ", =" + mMasterLists +
                    ", =" + mTsArrayList +
                    '}';
        }
    }
}
